<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<![endif]-->
<title>VIM 中文帮助: 创建自安装的 Vim 脚本</title>
<link rel="stylesheet" href="vim-stylesheet.css" type="text/css" />
<link rel="canonical" href="https://yianwillis.github.io/vimcdoc/doc/pi_vimball.html" />
<script type="text/javascript" src="vimcdoc.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body>
<nav id=banner>
<form action=tags.html target="tag_iframe">
  <input type="text" name="tag" id="tag" placeholder="标签搜索">
</form>
<iframe name="tag_iframe" src=""></iframe>
<a href="help.html">帮助总览</a> &middot;
<hr/>
<a href="quickref.html">快速参考</a> &middot;
<a href="index.html">命令索引</a> &middot;
<a href="eval.html#functions">函数列表</a> &middot;
<a href="quickref.html#option-list">选项列表</a> &middot;
<hr/>
<a href="usr_toc.html">用户手册</a> &middot;
<a href="help.html#reference_toc">参考手册</a> &middot;
</nav>

<header>
<h2>pi_vimball</h2>
</header>
<article id=outer>
<section class=inner>
<b class="vimtag"> <a name="pi_vimball.txt">pi_vimball.txt</a> </b>        适用于 Vim 9.0 版本。   最近更新: 2017年8月

</section><hr class="singleline" /><section class=inner>
                              Vimball 归档处理程序
</section><hr class="singleline" /><section class=inner>
                                <code class="vim">译者</code>: Willis

Author:  Charles E. Campbell  &lt;NcampObell@SdrPchip.AorgM-NOSPAM&gt;
          (remove NOSPAM from Campbell's email first)
Copyright: (c) 2004-2015 by Charles E. Campbell         <b class="vimtag"> <a name="Vimball-copyright">Vimball-copyright</a> </b>
        The VIM LICENSE (see  <a href="uganda.html#copyright">copyright</a> ) applies to the files in this
        package, including vimballPlugin.vim, vimball.vim, and pi_vimball.txt.
        except use "vimball" instead of "VIM".  Like anything else that's free,
        vimball.vim and its associated files are provided *as is* and comes with
        no warranty of any kind, either expressed or implied.  No guarantees
        of merchantability.  No guarantees of suitability for any purpose.  By
        using this plugin, you agree that in no event will the copyright
        holder be liable for any damages resulting from the use of this
        software. Use at your own risk!

</section><hr class="doubleline" /><section class=inner>
<h4>1. 内容                                 <b class="vimtag"> <a name="vba">vba</a> </b> <b class="vimtag"> <a name="vimball">vimball</a> </b> <b class="vimtag"> <a name="vimball-contents">vimball-contents</a> </b></h4>
        1. 内容..........................................:  <a href="pi_vimball.html#vimball-contents">vimball-contents</a> 
        2. Vimball 简介..................................:  <a href="pi_vimball.html#vimball-intro">vimball-intro</a> 
        3. Vimball 手册..................................:  <a href="pi_vimball.html#vimball-manual">vimball-manual</a> 
           MkVimball.....................................:  <a href="pi_vimball.html#:MkVimball">:MkVimball</a> 
           UseVimball....................................:  <a href="pi_vimball.html#:UseVimball">:UseVimball</a> 
           RmVimball.....................................:  <a href="pi_vimball.html#:RmVimball">:RmVimball</a> 
        4. Vimball 历史..................................:  <a href="pi_vimball.html#vimball-history">vimball-history</a> 


</section><hr class="doubleline" /><section class=inner>
<h4>2. Vimball 简介                                                 <b class="vimtag"> <a name="vimball-intro">vimball-intro</a> </b></h4>
        Vimball 的目标就是使插件用户的使用更方便。有了 vimball 以后，用户只需
        要: 
<code class="example">                vim someplugin.vba</code>
<code class="example">                :so %</code>
<code class="example">                :q</code>
        然后插件和它的所有部件都会被安装在合适的目录里。<code class="note">注意</code> 用户无须刻意进到
        某个特定的目录来执行此命令。另外，插件的帮助也会被自动安装。

        如果用户决定使用 AsNeeded 插件，vimball 会聪明地把本来要放到
        .vim/plugin/ 中的脚本放到 .vim/AsNeeded/ 里去。

        删除 vimball 安装的插件很容易: 
<code class="example">                vim</code>
<code class="example">                :RmVimball someplugin</code>
        举例说吧，zip 和 tarball 对应的操作就不是那么简单了。

        Vimball 检视用户的  <a href="options.html#'runtimepath'">'runtimepath'</a>  来确定把脚本放在哪里。如果可能，通
        常使用 runtimepath 提到的第一个目录。用 
<code class="example">                :echo &amp;rtp</code>
        来查看该目录。


</section><hr class="doubleline" /><section class=inner>
<h4>3. Vimball 手册                                         <b class="vimtag"> <a name="vimball-manual">vimball-manual</a> </b></h4>
创 建 VIMBALL                                                   <b class="vimtag"> <a name=":MkVimball">:MkVimball</a> </b>
                :<code class="special">[range]</code>MkVimball[!] filename <code class="special">[path]</code>

        行范围内指定要保存在 vimball 里的文件的路径，但不包含通常在
        runtimepath ( <a href="options.html#'rtp'">'rtp'</a> ) 指定的那部分。例如: 
<code class="example">                plugin/something.vim</code>
<code class="example">                doc/something.txt</code>
        在此范围的行上使用 
<code class="example">                :[range]MkVimball filename</code>

        建立文件 "filename.vba"，Vimball.vim 随后可以用它来还原那些文件。如果
        文件 "filename.vba" 已经存在，MKVimball 会给出<code class="note">警告</code>而不建立文件。<code class="note">注意</code>
        这些路径都相对于你的 .vim (vimfiles) 目录，而所有文件都应该在该目录
        下。更准确地说，vimball 插件通常使用 <a href="options.html#'runtimepath'">'runtimepath'</a> 里第一个存在的目录
        作为前缀；它不使用绝对路径，除非用户指定的就是如此。

        如果使用感叹号 (!)，MkVimball 总是建立 "filename.vba" 文件。如果已经存
        在则覆盖之。此行为和  <a href="editing.html#:w">:w</a>  类似。

        如要强制允许文件名中包含斜杠，也可用感叹号版本实现 (即 :MkVimball!
        path/filename)。

        <a href="http://vim.wikia.com/wiki/Using_VimBall_with_%27Make%27">http://vim.wikia.com/wiki/Using_VimBall_with_%27Make%27</a> 给出的技巧提供
        了用 make 自动生成 vimball 的好方法。


通 过 VIMBALL 建 立 目 录                               <b class="vimtag"> <a name="g:vimball_mkdir">g:vimball_mkdir</a> </b>

        首先尝试  <a href="builtin.html#mkdir()">mkdir()</a>  命令 (并非所有系统都支持)。

        如果该命令不存在，而且 g:vimball_mkdir 也不存在，它被设为: 
<code class="example">          |g:netrw_localmkdir|，如果存在的话</code>
<code class="example">          "mkdir"             ，如果可执行的话</code>
<code class="example">          "makedir"           ，如果可执行的话</code>
<code class="example">          否则                ，未定义</code>
        用户可以自定义 g:vimball_mkdir 来直接指定建立目录的命令。vimball 如有
        需要，会通过该命令来建立目录。

控 制 VIMBALL 提 取 目 录                               <b class="vimtag"> <a name="g:vimball_home">g:vimball_home</a> </b>

        通过指定变量 g:vimball_home，你可以覆盖  <a href="options.html#'runtimepath'">'runtimepath'</a>  的使用。

                                                        <b class="vimtag"> <a name="vimball-extract">vimball-extract</a> </b>
                vim filename.vba

        简单编辑一个 vimball 文件，Vimball.vim 会告诉用户必须执行 (source) 该
        归档的内容才能提取其中的文件。

        只有首行是 "Vimball Archiver by Charles E. Campbell" 的文件才会被认为
        是 vimball 文件，从而才会继续提取操作。

列 出 VIMBALL 中 的 文 件                               <b class="vimtag"> <a name=":VimballList">:VimballList</a> </b>

                :VimballList

        本命令告诉 Vim 列出归档里的所有文件，包括每个文件的行数。

手 动 执 行 VIMABALL 提 取                              <b class="vimtag"> <a name=":UseVimball">:UseVimball</a> </b>

                :UseVimball <code class="special">[path]</code>

        vimball 文件本身包含了该命令；它调用 vimball#Vimball() 例程，后者负责
        对 vimball 解包。用户可以手动执行该命令，而无须执行 vimball；用户还可
        以指定安装的路径来覆盖自动的选择，即  <a href="options.html#'runtimepath'">'runtimepath'</a>  里的第一个存在的
        目录。

删 除 VIMBALL                                           <b class="vimtag"> <a name=":RmVimball">:RmVimball</a> </b>

                :RmVimball vimballfile <code class="special">[path]</code>

        本命令删除制定 vimball 产生的所有文件 (但不包括它可能建立的任何目录)。
        用户也选择卸载文件的路径 (见  <a href="options.html#'runtimepath'">'runtimepath'</a> )；否则，缺省是
        <a href="options.html#'runtimepath'">'runtimepath'</a> 里的第一个存在的目录。
        为了实现这一点，该目录下包含一个文件 (.VimballRecord)，它包含了目前为
        止所有使用过的 vimball 中要删除的文件的记录。

禁 止 载 入

        如果由于某种原因你不想使用 vimball 提取插件，在 &lt;.vimrc&gt; 中加入以下两
        个变量就可以不载入 vimball.vim: 
<code class="example"></code>
<code class="example">                let g:loaded_vimballPlugin= 1</code>
<code class="example">                let g:loaded_vimball      = 1</code>

WINDDOWS                                                <b class="vimtag"> <a name="vimball-windows">vimball-windows</a> </b>

        许多 vimball 文件使用 gzip 压缩。Windows 不幸地没有自带解压 gzip 文件
        的工具。幸运的是，Windows 用户可以找到不少解压 gzip 的工具:

<code class="example">            项目     工具/套件    免费   网站</code>
<code class="example">            ----     ----------   ----   -------</code>
<code class="example">            7zip        工具       是    http://www.7-zip.org/</code>
<code class="example">            Winzip      工具       否    http://www.winzip.com/downwz.htm</code>
<code class="example">            unxutils    套件       是    http://unxutils.sourceforge.net/</code>
<code class="example">            cygwin      套件       是    http://www.cygwin.com/</code>
<code class="example">            GnuWin32    套件       是    http://gnuwin32.sourceforge.net/</code>
<code class="example">            MinGW       套件       是    http://www.mingw.org/</code>


</section><hr class="doubleline" /><section class=inner>
<h4>4. Vimball 历史 (英文)                                  <b class="vimtag"> <a name="vimball-history">vimball-history</a> </b> {{{1</h4>
        37 : Jul 18, 2014 * (by request of T. Miedema) added augroup around
                            the autocmds in vimballPlugin.vim
             Jul 06, 2015 * there are two uses of tabc; changed to tabc!
        34 : Sep 22, 2011 * "UseVimball path" now supports a non-full path by
                            prepending the current directory to it.
        33 : Apr 02, 2011 * Gave priority to *.vmb over *.vba
                          * Changed silent! to sil! (shorter)
                          * Safed  <a href="options.html#'swf'">'swf'</a>  setting (during vimball extraction,
                            its now turned off)
        32 : May 19, 2010 * (Christian Brabrandt) :so someplugin.vba and
                            :so someplugin.vba.gz (and the other supported
                            compression types) now works
                          * (Jan Steffens) added support for xz compression
                          * fenc extraction was erroneously picking up the
                            end of the line number when no file encoding
                            was present.  Fixed.
                          * By request, beginning the switchover from the vba
                            extension to vmb.  Currently both are supported;
                            MkVimball, however, now will create *.vmb files.
             Feb 11, 2011 * motoyakurotsu reported an error with vimball's
                            handling of zero-length files
             Feb 18, 2016 * Changed =~ to =~# where appropriate
        30 : Dec 08, 2008 * fnameescape() inserted to protect error
                            messaging using corrupted filenames from
                            causing problems
                          * RmVimball supports filenames that would
                            otherwise be considered to have "magic"
                            characters (ie. Abc[1].vba)
             Feb 18, 2009 * s:Escape(), g:vimball_shq, and g:netrw_shq
                            removed (shellescape() used directly)
             Oct 05, 2009 * (Nikolai Weibull) suggested that MkVimball
                            be allowed to use slashes in the filename.
        26 : May 27, 2008 * g:vimball_mkdir usage installed.  Makes the
                            $HOME/.vim (or $HOME\vimfiles) directory if
                            necessary.
             May 30, 2008 * (tnx to Bill McCarthy) found and fixed a bug:
                            vimball wasn't updating plugins to AsNeeded/
                            when it should
        25 : Mar 24, 2008 * changed vimball#Vimball() to recognize doc/*.??x
                            files as help files, too.
             Apr 18, 2008 * RmVimball command is now protected by saving and
                            restoring settings -- in particular, acd was
                            causing problems as reported by Zhang Shuhan
        24 : Nov 15, 2007 * g:vimball_path_escape used by s:Path() to
                            prevent certain characters from causing trouble
                            (defunct:  <a href="builtin.html#fnameescape()">fnameescape()</a>  and  <a href="builtin.html#shellescape()">shellescape()</a> 
                            now used instead)
        22 : Mar 21, 2007 * uses setlocal instead of set during BufEnter
        21 : Nov 27, 2006 * (tnx to Bill McCarthy) vimball had a header
                            handling problem and it now changes \s to /s
        20 : Nov 20, 2006 * substitute() calls have all had the 'e' flag
                            removed.
        18 : Aug 01, 2006 * vimballs now use folding to easily display their
                            contents.
                          * if a user has AsNeeded/somefile, then vimball
                            will extract plugin/somefile to the AsNeeded/
                            directory
        17 : Jun 28, 2006 * changes all \s to /s internally for Windows
        16 : Jun 15, 2006 * A. Mechelynck's idea to allow users to specify
                            installation root paths implemented for
                            UseVimball, MkVimball, and RmVimball.
                          * RmVimball implemented
        15 : Jun 13, 2006 * bugfix
        14 : May 26, 2006 * bugfixes
        13 : May 01, 2006 * exists("&amp;acd") used to determine if the acd
                            option exists
        12 : May 01, 2006 * bugfix - the  <a href="options.html#'acd'">'acd'</a>  option is not always defined
        11 : Apr 27, 2006 * VimballList would create missing subdirectories that
                            the vimball specified were needed.  Fixed.
        10 : Apr 27, 2006 * moved all setting saving/restoration to a pair of
                            functions.  Included some more settings in them
                            which frequently cause trouble.
        9  : Apr 26, 2006 * various changes to support Windows' prediction
                            for backslashes and spaces in file and directory
                            names.
        7  : Apr 25, 2006 * bypasses foldenable
                          * uses more exe and less norm! (:yank :put etc)
                          * does better at insuring a "Press ENTER" prompt
                            appears to keep its messages visible
        4  : Mar 31, 2006 * BufReadPost seems to fire twice; BufReadEnter
                            only fires once, so the "Source this file..."
                            message is now issued only once.
        3  : Mar 20, 2006 * removed query, now requires sourcing to be
                            extracted (:so %).  Message to that effect
                            included.
                          * :VimballList  now shows files that would be
                            extracted.
        2  : Mar 20, 2006 * query, :UseVimball included
        1  : Mar 20, 2006 * initial release


</section><hr class="doubleline" /><section class=inner>
<h4>vim:tw=78:ts=8:noet:ft=help:fdm=marker</h4></section>
</article>
<footer>
Generated by vim2html
</footer>
</body>
</html>
